<?php
/**
 * @link https://www.kancloud.cn/cleverstone/ymb2
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */
/* @var \yii\web\View $this */
use backend\assets\SiteAsset;
use builder\helper\App;

$flashError = Yii::$app->session->getFlash(App::params('admin.session.flash.error'));

SiteAsset::register($this);
$this->title = '后台系统登录';
?>
<div class="login-container" ng-controller="ym2.ctrl.site.login">
    <!-- 左侧图片和说明 -->
    <div class="login-image">
        <div class="image-content">
            <h2>欢迎回来</h2>
            <p><?= App::params('admin.slogan') ?></p>
            <svg class="illustration" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                <path d="M12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16Z" fill="white" fill-opacity="0.8"/>
                <path d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 13.6141 2.36787 15.1413 3.04004 16.4999L2 22L7.5001 20.9601C8.85876 21.6321 10.3859 22 12 22Z" fill="white" fill-opacity="0.6"/>
                <path d="M12 14C13.1046 14 14 13.1046 14 12C14 10.8954 13.1046 10 12 10C10.8954 10 10 10.8954 10 12C10 13.1046 10.8954 14 12 14Z" fill="white"/>
                <path d="M12 20C13.6569 20 15 18.6569 15 17C15 15.3431 13.6569 14 12 14C10.3431 14 9 15.3431 9 17C9 18.6569 10.3431 20 12 20Z" fill="white"/>
                <path d="M5.20711 18.2071L4.79289 17.7929C4.35858 18.5267 4.10557 19.4269 4.0644 20.3548L6.6452 20.1921C6.58793 19.4341 6.80341 18.7007 7.24289 18.0929L5.20711 18.2071Z" fill="white" fill-opacity="0.4"/>
                <path d="M18.0929 7.24289C18.7007 6.80341 19.4341 6.58793 20.1921 6.6452L20.3548 4.0644C19.4269 4.10557 18.5267 4.35858 17.7929 4.79289L18.0929 7.24289Z" fill="white" fill-opacity="0.4"/>
                <path d="M7.24289 5.90711L5.20711 6.02125C6.01267 5.66479 6.90966 5.5 7.82843 5.5L7.24289 5.90711Z" fill="white" fill-opacity="0.4"/>
                <path d="M18.7929 17.7929L19.2071 18.2071C19.6414 17.4733 19.8944 16.5731 19.9356 15.6452L17.3548 15.8079C17.4121 16.5659 17.1966 17.2993 16.7571 17.9071L18.7929 17.7929Z" fill="white" fill-opacity="0.4"/>
            </svg>
        </div>
    </div>

    <!-- 右侧登录表单 -->
    <div class="login-form">
        <div class="form-header">
            <div class="logo">
                <i class="fa fa-cog"></i>
            </div>
            <h1><?= App::params('admin.brandName') ?></h1>
            <p>账号登录，请输入您的账号和密码以继续</p>
        </div>

        <form class="layui-form" id="loginForm" name="LoginForm">
            <!-- 登录错误提示 -->
            <div ng-show="errorMessage" id="loginError" class="login-error">
                <i class="fa fa-exclamation-circle"></i>
                <span id="errorMessage">{{ errorMessage }}</span>
            </div>

<?php if (!empty($flashError)): ?>
            <!-- 公告位 -->
            <div class="announcement">
                <i class="fa fa-bullhorn"></i>
                <span><?= $flashError ?></span>
            </div>
<?php endif; ?>

            <div class="form-group">
                <label for="username" class="form-label">用户名</label>
                <input type="text" id="username" class="form-input" placeholder="请输入用户名" ng-model="username" lay-affix="clear" lay-filter="clear">
            </div>

            <div class="form-group">
                <label for="password" class="form-label">密码</label>
                <input type="password" id="password" class="form-input" placeholder="请输入密码" ng-model="password" lay-affix="eye">
            </div>

            <button type="submit" id="loginButton" class="btn-primary d-flex justify-content-center align-items-center mt-5" ng-click="loginSubmit($event)">
                <span>登录</span>
                <span ng-if="logining" class="loader"></span>
            </button>

            <!-- 安全认证标识 -->
            <div class="security-certifications">
                <div class="security-icon">
                    <i class="fa fa-copyright"></i>
                    <span><?= App::params('admin.copyright') ?></span>
                </div>
                <div class="security-icon">
                    <i class="fa fa-shield"></i>
                    <span><a style="color:inherit;" href="https://beian.miit.gov.cn/#/Integrated/index" target="_blank"><?= App::params('admin.icp') ?></a></span>
                </div>
            </div>
        </form>

        <div class="form-footer">
            <p>登录即表示您同意我们的<a href="#">服务条款</a>和<a href="#">隐私政策</a></p>
        </div>
    </div>
</div>
